#include "events.h"

#include <stdio.h>
#include <iostream>
#include "events.h"
#include "creature.h"

using namespace std;

Events::Events()
{
}

Events::Events(int time, Position place, int name, int race)
{
	m_when = time;
	m_where = place;
	m_object = name;
	m_species_o = race;
}

Events::~Events()
{
}
/*死亡，flag为3，获取死亡原因*/
void Events::get(int reason)
{
	m_flag_do = 3;
	m_flag_what = reason; /*此处what即为死因，1是老死2是重伤3是饿死*/
}
/*猎食，flag为1，获取被狩猎对象的名字和种族*/
void Events::get(Creature &c)
{
	m_flag_do = 1;
	m_subject = c.m_name;
	m_species_s = c.m_flag.race;
}
/*繁衍，flag为2，获取繁衍时目标对象的名字和种族，获取新生成对象的编号*/
void Events::get(Creature &c, int creature)
{
	m_flag_do = 2;
	m_subject = c.m_target.self->m_name;
	m_species_s = c.m_flag.race;
	m_flag_what = creature;
}

void Events::get_specise(int specise)
{
	switch (specise)
	{
	case 1:
		cout << "狼";
		break;
	case 2:
		cout << "羊";
		break;
	case 3:
		cout << "草";
		break;
	default:
		break;
	}
}

void Events::what()
{
}

void Events::show()
{
	cout << "时间" << m_when << "时,";
	get_specise(m_species_o);
	cout << m_object;
	cout << "在(" << m_where.x << "," << m_where.y << ")";
	switch (m_flag_do)
	{
	case 1:
		cout << "捕食了";
		get_specise(m_species_s);
		cout << m_subject << endl;
		break;
	case 2:
		cout << "和";
		get_specise(m_species_s);
		cout << m_subject << "繁衍了";
		get_specise(m_species_s);
		cout << m_flag_what << endl;
		break;
	case 3:
		cout << "死亡了,死因是";
		switch (m_flag_what) /*输出死因*/
		{
		case 1:
			cout << "衰老" << endl;
			break;
		case 2:
			cout << "重伤" << endl;
			break;
		case 3:
			cout << "饥饿" << endl;
			break;
		default:
			break;
		}
		break;
	default:
		break;
	}
	cout << endl;
}
